package tjs.study.notes.dotest.mongo;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.core.Ordered;
import org.springframework.stereotype.Component;

/**
 * Created by Nicky.Tang on 2021/12/11 9:21 下午
 *
 * @since 02.12.10
 */
@Aspect
@EnableAspectJAutoProxy(proxyTargetClass = true)//开启aop
@Component
public class DkdTransactionalAspect implements Ordered {
    @Pointcut(value = "@within(DkdTransactional)")
    public void point() {
    }

    @Around("point()")
    public Object around(ProceedingJoinPoint joinPoint) throws Throwable {
        System.out.println("进入自定义AT事务了。。。");
        Object res = joinPoint.proceed();
        System.out.println("退出自定义AT事务了。。。");
        return res;
    }

    @Override
    public int getOrder() {
        //return Integer.MAX_VALUE;//后于mongo提交事务
        return Integer.MIN_VALUE;//先于mongo提交事务
    }
}
